rm(list = ls())

# Parameters
Underline.v <- 2.3
Overline.v <- 3.5
Mu <- 2
Sd <- 1

# Figure 
v.full <- seq(1, 4.3, length.out = 1000)
labels.x.type <- c(expression(underline(v)), expression(paste(widehat(v), '*')), expression(bar(v)))

pdf('./figures/fig_1a.pdf', width = 7, height = 7)
plot(v.full, dnorm(v.full, mean = Mu, sd = Sd), 
     type = 'l', lwd = 4, 
     xlab = 'Threat of persecutation', ylab = 'Density', 
     cex.main = 1.5, cex.lab = 1.5, xaxt = 'n')
axis(1, at = c(Underline.v, (Underline.v + Overline.v)/2, Overline.v), 
     labels = labels.x.type, cex.axis = 1.5)
segments(x0 = Underline.v, y0 = 0, 
         x1 = Underline.v, 
         y1 = dnorm(Underline.v, mean = Mu, sd = Sd), 
         lwd = 3, lty = 2)
segments(x0 = (Underline.v + Overline.v)/2, y0 = 0, 
         x1 = (Underline.v + Overline.v)/2, 
         y1 = dnorm((Underline.v + Overline.v)/2, mean = Mu, sd = Sd), 
         lwd = 3, lty = 2)
segments(x0 = Overline.v, y0 = 0, 
         x1 = Overline.v, 
         y1 = dnorm(Overline.v, mean = Mu, sd = Sd), 
         lwd = 3, lty = 2)
text('Types not interested \n in applying', x = 1.6, y = 0.15, 
     cex = 1.45)
text('Ineligible types not\n applying', x = 3.2, y = 0.35, 
     cex = 1.45)
arrows(x0 = 2.6, y0 = 0.345, x1 = 2.6, y1 = 0.25, lwd = 2)
text('Applying ineligible \n types', x = 3.8, y = 0.28, 
     cex = 1.45)
arrows(x0 = 3.2, y0 = 0.27, x1 = 3.2, y1 = 0.12, lwd = 2)
text('Applying eligible \n types', x = 3.9, y = 0.18, 
     cex = 1.45)
arrows(x0 = 3.9, y0 = 0.15, x1 = 3.9, y1 = 0.04, lwd = 2)
dev.off()